/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.chl.project.carshop07.xml.jaxb;

import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;


/**
 *
 * @author AMADIN
 */
public class Marshaller {
    
    public static <T> void marshal(T t, OutputStream out) throws JAXBException{
        marshal(t, new OutputStreamWriter(out));
    }
    
    public static <T> void marshal(T t, Writer out) throws JAXBException{
        JAXBContext jc = JAXBContext.newInstance(t.getClass());
        javax.xml.bind.Marshaller m = jc.createMarshaller();
        m.setProperty( javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        m.marshal(t, out);
    }
}
